package com.guanzhi.restful;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 *  SpringBoot 实战
 * <p> Package: com.guanzhi.restful </p>
 * <p> File: Response.java </p>
 * <p> Description:  (统一响应工具类)</p>
 * <p> Date: 2024/2/5 18:07</p>
 *
 * @author 观之
 * @version 1.0 （代码版本）
 * @email <a href="mailto:guanzhi55634@aliyun.com">观之</a>（邮箱）
 * @date 2024/2/5 18:07
 * @since jdk17（jdk版本）
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Response {

    /**
     * 响应码
     */
    private String code;

    /**
     * 响应信息
     */
    private String message;

    /**
     * 响应数据
     */
    private Object data;

    public static Response success() {
        return new Response("200", "success", null);
    }

    public static Response success(Object data) {
        return new Response("200", "success", data);
    }

    public static Response success(String message, Object data) {
        return new Response("200", message, data);
    }

    public static Response error() {
        return new Response("500", "error", null);
    }
    public static Response error(String message) {
        return new Response("500", message, null);
    }

    public static Response error(String message, Object data) {
        return new Response("500", message, data);
    }
}
